/*
 * Copyright 2025 arisgo@163.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.arisgo.cloud.web.model;

import io.swagger.v3.oas.annotations.media.Schema;

import java.util.ArrayList;
import java.util.List;

/**
 * 用于vo
 *
 * @author Coulson
 * @since 2023-7-2
 */
public class NumberIdWithTree<T extends NumberId> extends NumberId implements ITree<T> {
    @Schema(name = "parentId", description = "父类id")
    private Long parentId;
    @Schema(name = "sort", description = "排序")
    private Integer sort;
    @Schema(name = "children", description = "子集")
    private List<T> children;

    @Override
    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    @Override
    public Long getParentId() {
        return this.parentId;
    }

    @Override
    public void setChildren(List<T> children) {
        this.children = children;
    }

    @Override
    public List<T> getChildren() {
        return this.children;
    }

    @Override
    public void setSort(Integer sort) {
        this.sort = sort;
    }

    @Override
    public Integer getSort() {
        return this.sort;
    }

    public static final String SORT = "sort";
    public static final String CHILDREN = "children";
    public static final String PARENT_ID = "parent_id";

    public static String[] getDefaultColumnName() {
        List<String> columns = new ArrayList<>(List.of(NumberIdWithTime.getDefaultColumnName()));
        columns.addAll(new ArrayList<>(List.of(PARENT_ID, SORT, CHILDREN)));
        return columns.toArray(new String[9]);
    }
}
